<template>
  <div class="common_option_btns">
    <template v-for="item in btnList">
      <template v-if="item.eventName === 'del'">
        <el-popconfirm
          v-bind="item.prop"
          @confirm="handleBtnClick(item.eventName)"
        >
          <template #reference>
            <el-button :type="item.type || 'info'" size="small">{{ item.text || '删除' }}</el-button>
          </template>
        </el-popconfirm>
      </template>
      <el-button
        v-else
        :type="item.type"
        :size="item.size"
        @click="handleBtnClick(item.eventName)"
      >
        {{ item.text }}
      </el-button>
    </template>
  </div>
</template>

<script setup>
defineProps({
  btnList: {
    type: Array,
    default: () => [],
  },
});
const emits = defineEmits(["btn-click"]);
const handleBtnClick = (eventName) => {
  emits("btn-click", eventName);
};
</script>